package com.wechat.core.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.wechat.core.common.WeChatContant;
import com.wechat.core.service.AbstractService;
import com.wechat.core.service.UserInfoService;
import com.wechat.core.util.HttpClientUtils;
import com.wechat.core.util.TokenManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author hgb
 * @date 2019/1/26
 * Email xhy18650@sina.com
 */
@Service
public class UserInfoServiceImpl extends AbstractService implements UserInfoService {

    @Override
    public Map<String, Object> getUserInfo(String openId) {
        Map<String, Object> params = getParams();
        params.put("openid", openId);
        try {
            String result = HttpClientUtils.httpGetRequest(USER_INFO_URL, params);
            JSONObject jsonObject = JSON.parseObject(result);
            return jsonObject;
        } catch (Exception e) {
            e.printStackTrace();
            logger.debug("获取用户信息异常 openid{}",openId);

        }
        return null;
    }


}
